package io.kiki.stack.http.feign.form;

import feign.RequestTemplate;
import feign.codec.EncodeException;

import java.nio.charset.Charset;
import java.util.Map;

/**
 * Interface for content processors.
 *
 * @author Artem Labazin
 * @see MultipartFormContentProcessor
 * @see UrlencodedFormContentProcessor
 */
public interface ContentProcessor {

    /**
     * A content type header name.
     */
    String CONTENT_TYPE_HEADER = "Content-Type";

    /**
     * End line symbols.
     */
    String CRLF = "\r\n";

    /**
     * Processes a request.
     *
     * @param template Feign's request template.
     * @param charset  request charset from 'Content-Type' header (UTF-8 by default).
     * @param data     reqeust data.
     * @throws EncodeException in case of any encode exception
     */
    void process(RequestTemplate template, Charset charset, Map<String, Object> data) throws EncodeException;

    /**
     * Returns supported {@link ContentType} of this processor.
     *
     * @return supported content type enum value.
     */
    ContentType getSupportedContentType();
}
